var a = getApp(), t = require("../../utils/util.js");

Page({
    data: {
        sx: [ "鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪" ],
        array: [ "肖鼠", "肖牛", "肖虎", "肖兔", "肖龙", "肖蛇", "肖马", "肖羊", "肖猴", "肖鸡", "肖狗", "肖猪" ],
        maleid: 0,
        smaleid: 0,
        topNum: a.globalData.topNum
    },
    onLoad: function(a) {
        var t = this, o = a.maleid;
        if (o) {
            for (var n = 0; n < t.data.topNum.length; n++) o == t.data.topNum[n] && (o = n);
            this.setData({
                maleid: o,
                smaleid: o
            });
        }
        t.startPair(t.data.maleid);
    },
    bindPickerChange: function(a) {
        this.setData({
            smaleid: a.detail.value
        });
    },
    startPair: function(a) {
        this.setData({
            maleid: this.data.smaleid
        }), console.log("id", this.data.maleid), this.showInfo(parseInt(this.data.maleid) + 1);
    },
    showInfo: function(a) {
        var o = this;
        t.getPairTopData(o, "sx", a, function() {
            o.data.infodata, console.log("数据", o.data.infodata), o.dealArr(o.data.infodata);
        });
    },
    dealArr: function(a) {
        for (var t = this, o = 0; o < a.length; o++) {
            var n = a[o];
            n.female.cont = n.female.cont.substring(0, 30) + "...", n.male.cont = n.male.cont.substring(0, 30) + "...", 
            n.id = t.data.sx.findIndex(function(a) {
                return a == n.name;
            }) + 1;
        }
        t.setData({
            pairList: a
        });
    },
    scrollTop: function() {
        wx.pageScrollTo({
            scrollTop: 0,
            duration: 300
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function(a) {
        return "button" === a.from && console.log(a.target), {
            title: "生肖配对排行",
            path: "/pages/pairtop_sx/pairtop_sx?maleid=" + this.data.maleid
        };
    }
});